
import binascii
from gmssl.sm4 import CryptSM4, SM4_DECRYPT, SM4_ENCRYPT

crypt_sm4 = CryptSM4()

def decrypt_ecb_from_hex(encrypted_hex: str, hex_key: str):
    key = bytes.fromhex(hex_key)
    enc_bytes = binascii.unhexlify(encrypted_hex)
    crypt_sm4.set_key(key, SM4_DECRYPT)
    decrypted = crypt_sm4.crypt_ecb(enc_bytes) #  bytes类型
    #print('decrypted: ', decrypted)
    return decrypted.decode('utf-8')

def init_ip_white_list():
    pass